package cn.wizzer.app.user.modules.models;


import cn.wizzer.app.user.modules.models.enums.PayChannel;
import cn.wizzer.app.user.modules.models.enums.RechargeStatusEnum;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@Table("user_recharge")
@TableIndexes({@Index(name = "unique_no", fields = {"no"}, unique = true),
        @Index(name = "INDEX_CT_AT", fields = {"ctAt"}, unique = false)})
public class UserRecharge extends BaseModel implements Serializable {

    @Column
    @Name
    @Comment("ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(uu32 = true)
    private String id;

    @Column
    @Comment("编号")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String no;

    @Column
    @Comment("第三方充值单号")
    @ColDefine(type = ColType.VARCHAR, width = 256)
    private String outNo;

    @Column
    @Comment("卡号")
    @ColDefine(type = ColType.VARCHAR, width = 128)
    private String cardNo;

    @Column
    @Comment("卡ID/walletAddress")
    @ColDefine(type = ColType.VARCHAR, width = 128)
    private String address;

    @Column
    @Comment("用户ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String userId;

    @Comment("付款人姓名/付款地址")
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 16)
    private String payer;

    @Column
    @Comment("备注")
    @ColDefine(type = ColType.VARCHAR, width = 128)
    private String remark;

    @Column
    @Comment("通道")
    @ColDefine(type = ColType.VARCHAR, width = 128)
    private PayChannel channel;
    /**
     * 累计充值成功次数，非后台
     */
    @Column
    @Comment("累计充值成功次数")
    @ColDefine(type = ColType.INT)
    @Default("0")
    private Integer times;

    @Column
    @Comment("充值金额")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    private BigDecimal amount;

    @Comment("币种ID")
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 32, notNull = true)
    private String currencyId;

    /**
     * 待到账状态需要可以做入账（已到账）处理，以及不入账（支付异常（失败））处理
     */
    @Column
    @Comment("状态->-1:取消0:待确认1:待到账2:成功3:失败")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private RechargeStatusEnum status;

    @Column
    @ColDefine(type = ColType.VARCHAR, width = 4)
    private String sign;

    @Column
    @Comment("创建时间")
    @PrevInsert(els = @EL("$me.now()"))
    //Long不要用ColDefine定义,兼容oracle/mysql,支持2038年以后的时间戳
    private Long ctAt;

    @Column
    @Comment("取消时间")
    private Long cancelAt;

    @Column
    @Comment("支付时间")
    private Long paymentAt;

    @Column
    @Comment("审批时间")
    private Long examineAt;


}
